package com.qfmy.web.app.config;

import com.qfmy.web.app.service.listenBook.AudioResourceService;
import com.qfmy.web.app.service.novel.NovelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * 当程序启动时执行
 */
@Lazy
@Component
@SuppressWarnings("all")
public class AppStartupRunner implements CommandLineRunner {
    /**
     * 注入小说service
     */
    @Autowired
    private NovelService novelService;

    /**
     * 注入音频service
     */
    @Autowired
    private AudioResourceService audioResourceService;

    /**
     * 当程序启动时执行
     * @param args
     * @throws Exception
     */
    @Override
    public void run(String... args) throws Exception {
        // 索引小说
        novelService.indexBooks();
        // 索引音频
        audioResourceService.indexAudios();
    }
}